import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import p001 from './p001';
import p002 from './p002';
import set from '@dfeidao/atom-web/local/set';
import p003 from './p003';
import p004 from './p004';
import get from '@dfeidao/atom-web/local/get';

export default async function a001(fd: IFeidaoAiBrowserComponent, no: string, na: string) {
	// todo
	//console.log('zj4来的', no);
	const res = await nodejs<{ dt: Array<{ equipment_kind_no: string }>, t: number }>('device-type/zj-000005/s001', {
		filter: {
			equip_type_no: no,
			equipment_kind_name: '',
			pn: 1,
		}
	});

	const arr: String[] = [];
	res.dt.forEach((v) => {
		arr.push(v.equipment_kind_no);
	});
	//console.log(arr);
	render(fd, res.dt, p001, 'p001', 'inner');
	render(fd, res.t, p002, 'p002', 'inner');
	render(fd, res, p003, 'p003', 'inner');
	render(fd, res, p004, 'p004', 'inner');
	if (na) {
		const name = fd.data.node.querySelector<HTMLSpanElement>('[data-id="equip_type_name"]');
		name.innerHTML = na;
	} else {
		const na1 = get(fd, 'name') as string;
		const name = fd.data.node.querySelector<HTMLSpanElement>('[data-id="equip_type_name"]');
		name.innerHTML = na1;
	}


	set(fd, 'no', no);

}
